# -*- coding: utf-8 -*-
from tools.mysqlconn import NBAdb
from mysql_text import sql_create_text
from spider_get.get_team_name import Name
from spider_get.get_team_base_data import Base
from spider_get.get_team_player_data import Player
from spider_get.get_team_salary_data import Salary


class Team:

    def __init__(self):
        """
        初始化一些数据。
        """
        # 实例化数据库管理方法
        self._instance_one = NBAdb()

    def create_table(self):
        """
        批量创建数据表。
        :return:
        """
        # 1
        self._instance_one.create_table(sql_create_text.nba_active_team)

        # 2
        self._instance_one.create_table(sql_create_text.nba_history_team)

        # 3
        self._instance_one.create_table(sql_create_text.team_brief_introduction)

        # 4
        self._instance_one.create_table(sql_create_text.team_player_date_regular)

        # 5
        self._instance_one.create_table(sql_create_text.team_player_count_data_regular)

        # 6
        self._instance_one.create_table(sql_create_text.team_player_date_playoff)

        # 7
        self._instance_one.create_table(sql_create_text.team_player_count_data_playoff)

        # 8
        self._instance_one.create_table(sql_create_text.team_salary_situation)

        # 9
        self._instance_one.create_table(sql_create_text.team_salary_count)

        # 10
        self._instance_one.create_table(sql_create_text.team_regular_star_score_total)

        # 11
        self._instance_one.create_table(sql_create_text.team_regular_star_score_average)

        # 12
        self._instance_one.create_table(sql_create_text.team_regular_star_backboard_total)

        # 13
        self._instance_one.create_table(sql_create_text.team_regular_star_backboard_average)

        # 14
        self._instance_one.create_table(sql_create_text.team_regular_star_assists_total)

        # 15
        self._instance_one.create_table(sql_create_text.team_regular_star_assists_average)

        # 16
        self._instance_one.create_table(sql_create_text.team_regular_star_steal_total)

        # 17
        self._instance_one.create_table(sql_create_text.team_regular_star_steal_average)

        # 18
        self._instance_one.create_table(sql_create_text.team_regular_star_cap_total)

        # 19
        self._instance_one.create_table(sql_create_text.team_regular_star_cap_average)

        # 20
        self._instance_one.create_table(sql_create_text.team_regular_star_mistake_total)

        # 21
        self._instance_one.create_table(sql_create_text.team_regular_star_mistake_average)

        # 22
        self._instance_one.create_table(sql_create_text.team_regular_star_foul_total)

        # 23
        self._instance_one.create_table(sql_create_text.team_regular_star_foul_average)

        # 24
        self._instance_one.create_table(sql_create_text.team_regular_star_hit_total)

        # 25
        self._instance_one.create_table(sql_create_text.team_regular_star_hit_rate)

        # 26
        self._instance_one.create_table(sql_create_text.team_regular_star_ture_hit)

        # 27
        self._instance_one.create_table(sql_create_text.team_regular_star_tp_total)

        # 28
        self._instance_one.create_table(sql_create_text.team_regular_star_tp_hit_rate)

        # 29
        self._instance_one.create_table(sql_create_text.team_regular_star_penalty_total)

        # 30
        self._instance_one.create_table(sql_create_text.team_regular_star_penalty_hit_rate)

        # 31
        self._instance_one.create_table(sql_create_text.team_regular_star_undefined_total)

        # 32
        self._instance_one.create_table(sql_create_text.team_regular_star_undefined_average)

        # 33
        self._instance_one.create_table(sql_create_text.team_regular_star_appearance)

        # 34
        self._instance_one.create_table(sql_create_text.team_playoff_star_score_total)

        # 35
        self._instance_one.create_table(sql_create_text.team_playoff_star_score_average)

        # 36
        self._instance_one.create_table(sql_create_text.team_playoff_star_backboard_total)

        # 37
        self._instance_one.create_table(sql_create_text.team_playoff_star_backboard_average)

        # 38
        self._instance_one.create_table(sql_create_text.team_playoff_star_assists_total)

        # 39
        self._instance_one.create_table(sql_create_text.team_playoff_star_assists_average)

        # 40
        self._instance_one.create_table(sql_create_text.team_playoff_star_steal_total)

        # 41
        self._instance_one.create_table(sql_create_text.team_playoff_star_steal_average)

        # 42
        self._instance_one.create_table(sql_create_text.team_playoff_star_cap_total)

        # 43
        self._instance_one.create_table(sql_create_text.team_playoff_star_cap_average)

        # 44
        self._instance_one.create_table(sql_create_text.team_playoff_star_mistake_total)

        # 45
        self._instance_one.create_table(sql_create_text.team_playoff_star_mistake_average)

        # 46
        self._instance_one.create_table(sql_create_text.team_playoff_star_foul_total)

        # 47
        self._instance_one.create_table(sql_create_text.team_playoff_star_foul_average)

        # 48
        self._instance_one.create_table(sql_create_text.team_playoff_star_hit_total)

        # 49
        self._instance_one.create_table(sql_create_text.team_playoff_star_hit_rate)

        # 50
        self._instance_one.create_table(sql_create_text.team_playoff_star_ture_hit)

        # 51
        self._instance_one.create_table(sql_create_text.team_playoff_star_tp_total)

        # 52
        self._instance_one.create_table(sql_create_text.team_playoff_star_tp_hit_rate)

        # 53
        self._instance_one.create_table(sql_create_text.team_playoff_star_penalty_total)

        # 54
        self._instance_one.create_table(sql_create_text.team_playoff_star_penalty_hit_rate)

        # 55
        self._instance_one.create_table(sql_create_text.team_playoff_star_undefined_total)

        # 56
        self._instance_one.create_table(sql_create_text.team_playoff_star_undefined_average)

        # 57
        self._instance_one.create_table(sql_create_text.team_playoff_star_appearance)

        # 58
        self._instance_one.create_table(sql_create_text.team_superstar_peak_season_data)

        del self._instance_one

    def get_data(self):
        """
        批量获取数据，并插入数据表中。
        :return:
        """
        # # 获取球队的队名
        # Name().get_active_team()
        # Name().get_history_team()

        # 获取球队的基本数据
        # Base().get_team_brief_introduction()
        # Base().get_team_superstar_data()
        # Base().get_team_superstar_peak_season()

        # 获取球队历年效力球员数据
        # Player().get_player_regular_data()
        # Player().get_player_playoff_data()

        # 获取球队历年薪金状况
        Salary().get_salary()

    def run(self):
        """
        执行。
        :return:
        """
        # self.create_table()
        self.get_data()


if __name__ == '__main__':
    Team().run()
